package com.taobao.api.request;

import java.util.Date;
import java.util.Map;

import com.taobao.api.ApiRuleException;
import com.taobao.api.TaobaoRequest;
import com.taobao.api.internal.util.RequestCheckUtils;
import com.taobao.api.internal.util.TaobaoHashMap;
import com.taobao.api.response.WlbExtorderCreateResponse;

/**
 * TOP API: taobao.wlb.extorder.create request
 * 
 * @author auto create
 * @since 1.0, 2013-07-21 16:38:14
 */
public class WlbExtorderCreateRequest implements TaobaoRequest<WlbExtorderCreateResponse> {

  private Map<String, String> headerMap = new TaobaoHashMap();
  private TaobaoHashMap       udfParams;                      // add
                                                              // user-defined
                                                              // text parameters
  private Long                timestamp;

  /**
   * 买家昵称
   */
  private String              buyerNick;

  /**
   * 期望结束时间，在入库单会使用到
   */
  private Date                expectEndTime;

  /**
   * 计划开始送达时间 在入库单中可能会使用
   */
  private Date                expectStartTime;

  /**
   * 用字符串格式来表示订单标记列表：比如COD^PRESELL^SPLIT^LIMIT 等，中间用“^”来隔开
   * ----------------------------------------
   * 订单标记list（所有字母全部大写）1:COD-货到付款,2:LIMIT-限时配送,3:PRESELL-预售,4:INVOICE-需要发票,5:
   * COMPLAIN-已投诉,6:MERGE-合单,7:SPLIT-拆单,8: EXCHANGE-退换货， 9:VISIT-上门
   * ,10:MODIFYTRANSPORT-可改配送方式,11:CONSIGN-代理已发货通知,
   * 12:SELLER_AFFORD-卖家承担运费,13:SYNC_RETURN_BILL-同时退回发票,14: FENXIAO-分销订单标志
   */
  private String              extFlag;

  /**
   * 外部单据编号
   */
  private String              extOrderCode;

  /**
   * 外部订单来源： （1）LC：推荐物流 （2）EXT：wlb_ext （3）ERP：erp （4）WMS： WMS盘点 （5）FENXIAO：分销
   * (6) OMS: OMS （7）ELINK： ELINK
   */
  private String              extOrderSource;

  /**
   * 引起当前单据的前一个单据的编号
   */
  private String              extPrevOrderId;

  /**
   * {"invoince_info": [{"bill_type":"发票类型，必选", "bill_title":"发票抬头，必选",
   * "bill_amount":"发票金额(单位是分)，必选","bill_content":"发票内容，可选"}]}
   */
  private String              invoinceInfo;

  /**
   * 1:NORM-正常订单,2:RETURN-退货订单,3:SWITCH-换货订单
   */
  private String              opMainType;

  /**
   * 外部交易号
   */
  private String              operateCode;

  /**
   * 订单类型： （1）OTHER： 其他 （2）TBTRADE： 淘宝交易 （3）OTHER_TRADE：其他交易
   * （4）COORDINATE：调拨（5）ALLOCATION： 盘点 （6）STOCK:采购
   */
  private String              operateType;

  /**
   * 订单商品列表： {"order_item_list":[{" sub_trade_code "
   * :"可选,淘宝子交易号","item_id":"必须,商品Id","item_code":"必须,商家编码","item_name":
   * "可选,物流宝商品名称","item_quantity":"必选,计划数量","item_price":"必选,物品价格,单位为分",
   * "owner_user_nick ":"可选,货主nick 代销模式下会存在","flag":"判断是否为赠品0 不是1是"
   * ,"picture_url":"图片Url","remarks":"可选,备注","inventory_type":
   * "必须，库存类型1 可销售库存 101 类型用来定义残次品 201 冻结类型库存 301 在途库存"]}
   */
  private String              orderItemList;

  /**
   * 订单类型：（1）INBOUND：入库（2）OUTBOUND：出库（3）ALLOCATE：调拨（4）RETURN_IN:退货入库
   */
  private String              orderType;

  /**
   * 包裹件数，入库单和出库单中会用到
   */
  private Long                packageCount;

  /**
   * 运费，以分为单位
   */
  private Long                postage;

  /**
   * 发收方发货方信息必须传 手机和电话必选其一 收货方信息 邮编^^^省^^^市^^^区^^^具体地址^^^收件方名称^^^手机^^^电话
   * 如果某一个字段的数据为空时，必须传NA
   */
  private String              receiverInfo;

  /**
   * 备注
   */
  private String              remark;

  /**
   * 零售商
   */
  private String              retailer;

  /**
   * 退货时的运单号
   */
  private String              returnTmsCode;

  /**
   * 投递时间范围要求,格式'15:20'用分号隔开
   */
  private String              scheduleEnd;

  /**
   * 投递时间范围要求,格式'13:20'用分号隔开
   */
  private String              scheduleStart;

  /**
   * 投递时延要求: （1）INSTANT_ARRIVED： 当日达 （2）TOMMORROY_MORNING_ARRIVED：次晨达
   * （3）TOMMORROY_ARRIVED：次日达 （4）工作日：WORK_DAY （5）节假日：WEEKED_DAY
   */
  private String              scheduleType;

  /**
   * 发货方信息，发收方发货方信息必须传 手机和电话必选其一 邮编^^^省^^^市^^^区^^^具体地址^^^收件方名称^^^手机^^^电话
   * 如果某一个字段的数据为空时，必须传NA
   */
  private String              senderInfo;

  /**
   * 服务费用，以分为单位
   */
  private Long                serviceFee;

  /**
   * 物流运送方式: （1）MAIL:平邮 （2）EXPRESS :快递？ (3) EMS: EMS (4) OTHER:其他
   */
  private String              shippingType;

  /**
   * 子订单外部订单编号
   */
  private String              subExtOrderCode;

  /**
   * 快递公司的代码
   */
  private String              tmsCode;

  /**
   * 卖家建议的物流公司编码,或者退货时的发货公司编码
   */
  private String              tmsTpCode;

  /**
   * 物品总价，以分为单位
   */
  private Long                totalPrice;

  /**
   * 交易订单类型，1：MAIN-表示主订单，2：SUB-表示子订单
   */
  private String              tradeOrderType;

  /**
   * 仓库的代码
   */
  private String              wmsCode;

  /**
   * 调拨单目地仓库
   */
  private String              wmsCodeDestination;

  public void setBuyerNick(String buyerNick) {
    this.buyerNick = buyerNick;
  }

  public String getBuyerNick() {
    return this.buyerNick;
  }

  public void setExpectEndTime(Date expectEndTime) {
    this.expectEndTime = expectEndTime;
  }

  public Date getExpectEndTime() {
    return this.expectEndTime;
  }

  public void setExpectStartTime(Date expectStartTime) {
    this.expectStartTime = expectStartTime;
  }

  public Date getExpectStartTime() {
    return this.expectStartTime;
  }

  public void setExtFlag(String extFlag) {
    this.extFlag = extFlag;
  }

  public String getExtFlag() {
    return this.extFlag;
  }

  public void setExtOrderCode(String extOrderCode) {
    this.extOrderCode = extOrderCode;
  }

  public String getExtOrderCode() {
    return this.extOrderCode;
  }

  public void setExtOrderSource(String extOrderSource) {
    this.extOrderSource = extOrderSource;
  }

  public String getExtOrderSource() {
    return this.extOrderSource;
  }

  public void setExtPrevOrderId(String extPrevOrderId) {
    this.extPrevOrderId = extPrevOrderId;
  }

  public String getExtPrevOrderId() {
    return this.extPrevOrderId;
  }

  public void setInvoinceInfo(String invoinceInfo) {
    this.invoinceInfo = invoinceInfo;
  }

  public String getInvoinceInfo() {
    return this.invoinceInfo;
  }

  public void setOpMainType(String opMainType) {
    this.opMainType = opMainType;
  }

  public String getOpMainType() {
    return this.opMainType;
  }

  public void setOperateCode(String operateCode) {
    this.operateCode = operateCode;
  }

  public String getOperateCode() {
    return this.operateCode;
  }

  public void setOperateType(String operateType) {
    this.operateType = operateType;
  }

  public String getOperateType() {
    return this.operateType;
  }

  public void setOrderItemList(String orderItemList) {
    this.orderItemList = orderItemList;
  }

  public String getOrderItemList() {
    return this.orderItemList;
  }

  public void setOrderType(String orderType) {
    this.orderType = orderType;
  }

  public String getOrderType() {
    return this.orderType;
  }

  public void setPackageCount(Long packageCount) {
    this.packageCount = packageCount;
  }

  public Long getPackageCount() {
    return this.packageCount;
  }

  public void setPostage(Long postage) {
    this.postage = postage;
  }

  public Long getPostage() {
    return this.postage;
  }

  public void setReceiverInfo(String receiverInfo) {
    this.receiverInfo = receiverInfo;
  }

  public String getReceiverInfo() {
    return this.receiverInfo;
  }

  public void setRemark(String remark) {
    this.remark = remark;
  }

  public String getRemark() {
    return this.remark;
  }

  public void setRetailer(String retailer) {
    this.retailer = retailer;
  }

  public String getRetailer() {
    return this.retailer;
  }

  public void setReturnTmsCode(String returnTmsCode) {
    this.returnTmsCode = returnTmsCode;
  }

  public String getReturnTmsCode() {
    return this.returnTmsCode;
  }

  public void setScheduleEnd(String scheduleEnd) {
    this.scheduleEnd = scheduleEnd;
  }

  public String getScheduleEnd() {
    return this.scheduleEnd;
  }

  public void setScheduleStart(String scheduleStart) {
    this.scheduleStart = scheduleStart;
  }

  public String getScheduleStart() {
    return this.scheduleStart;
  }

  public void setScheduleType(String scheduleType) {
    this.scheduleType = scheduleType;
  }

  public String getScheduleType() {
    return this.scheduleType;
  }

  public void setSenderInfo(String senderInfo) {
    this.senderInfo = senderInfo;
  }

  public String getSenderInfo() {
    return this.senderInfo;
  }

  public void setServiceFee(Long serviceFee) {
    this.serviceFee = serviceFee;
  }

  public Long getServiceFee() {
    return this.serviceFee;
  }

  public void setShippingType(String shippingType) {
    this.shippingType = shippingType;
  }

  public String getShippingType() {
    return this.shippingType;
  }

  public void setSubExtOrderCode(String subExtOrderCode) {
    this.subExtOrderCode = subExtOrderCode;
  }

  public String getSubExtOrderCode() {
    return this.subExtOrderCode;
  }

  public void setTmsCode(String tmsCode) {
    this.tmsCode = tmsCode;
  }

  public String getTmsCode() {
    return this.tmsCode;
  }

  public void setTmsTpCode(String tmsTpCode) {
    this.tmsTpCode = tmsTpCode;
  }

  public String getTmsTpCode() {
    return this.tmsTpCode;
  }

  public void setTotalPrice(Long totalPrice) {
    this.totalPrice = totalPrice;
  }

  public Long getTotalPrice() {
    return this.totalPrice;
  }

  public void setTradeOrderType(String tradeOrderType) {
    this.tradeOrderType = tradeOrderType;
  }

  public String getTradeOrderType() {
    return this.tradeOrderType;
  }

  public void setWmsCode(String wmsCode) {
    this.wmsCode = wmsCode;
  }

  public String getWmsCode() {
    return this.wmsCode;
  }

  public void setWmsCodeDestination(String wmsCodeDestination) {
    this.wmsCodeDestination = wmsCodeDestination;
  }

  public String getWmsCodeDestination() {
    return this.wmsCodeDestination;
  }

  public Long getTimestamp() {
    return this.timestamp;
  }

  public void setTimestamp(Long timestamp) {
    this.timestamp = timestamp;
  }

  public String getApiMethodName() {
    return "taobao.wlb.extorder.create";
  }

  public Map<String, String> getTextParams() {
    TaobaoHashMap txtParams = new TaobaoHashMap();
    txtParams.put("buyer_nick", this.buyerNick);
    txtParams.put("expect_end_time", this.expectEndTime);
    txtParams.put("expect_start_time", this.expectStartTime);
    txtParams.put("ext_flag", this.extFlag);
    txtParams.put("ext_order_code", this.extOrderCode);
    txtParams.put("ext_order_source", this.extOrderSource);
    txtParams.put("ext_prev_order_id", this.extPrevOrderId);
    txtParams.put("invoince_info", this.invoinceInfo);
    txtParams.put("op_main_type", this.opMainType);
    txtParams.put("operate_code", this.operateCode);
    txtParams.put("operate_type", this.operateType);
    txtParams.put("order_item_list", this.orderItemList);
    txtParams.put("order_type", this.orderType);
    txtParams.put("package_count", this.packageCount);
    txtParams.put("postage", this.postage);
    txtParams.put("receiver_info", this.receiverInfo);
    txtParams.put("remark", this.remark);
    txtParams.put("retailer", this.retailer);
    txtParams.put("return_tms_code", this.returnTmsCode);
    txtParams.put("schedule_end", this.scheduleEnd);
    txtParams.put("schedule_start", this.scheduleStart);
    txtParams.put("schedule_type", this.scheduleType);
    txtParams.put("sender_info", this.senderInfo);
    txtParams.put("service_fee", this.serviceFee);
    txtParams.put("shipping_type", this.shippingType);
    txtParams.put("sub_ext_order_code", this.subExtOrderCode);
    txtParams.put("tms_code", this.tmsCode);
    txtParams.put("tms_tp_code", this.tmsTpCode);
    txtParams.put("total_price", this.totalPrice);
    txtParams.put("trade_order_type", this.tradeOrderType);
    txtParams.put("wms_code", this.wmsCode);
    txtParams.put("wms_code_destination", this.wmsCodeDestination);
    if (this.udfParams != null) {
      txtParams.putAll(this.udfParams);
    }
    return txtParams;
  }

  public void putOtherTextParam(String key, String value) {
    if (this.udfParams == null) {
      this.udfParams = new TaobaoHashMap();
    }
    this.udfParams.put(key, value);
  }

  public Class<WlbExtorderCreateResponse> getResponseClass() {
    return WlbExtorderCreateResponse.class;
  }

  public void check() throws ApiRuleException {
    RequestCheckUtils.checkNotEmpty(extOrderCode, "extOrderCode");
    RequestCheckUtils.checkNotEmpty(extOrderSource, "extOrderSource");
    RequestCheckUtils.checkNotEmpty(operateType, "operateType");
    RequestCheckUtils.checkNotEmpty(orderItemList, "orderItemList");
    RequestCheckUtils.checkNotEmpty(orderType, "orderType");
    RequestCheckUtils.checkNotEmpty(retailer, "retailer");
  }

  public Map<String, String> getHeaderMap() {
    return headerMap;
  }
}
